<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>优惠券派送</title>
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link href="/Public/css/animate.css" rel="stylesheet">
    <link rel="stylesheet" href="/Public/css/toast.css">
    <link rel="stylesheet" href="/Public/css/gxxjkefu-normalize.css">
    <link rel="stylesheet" href="/Public/css/model.css">
    <style>
        .content_box {
            margin: 0 auto;
            width: 80%;
        }

        .content_box span {
            display: inline-block;
            width: 100px;
        }

        .content_box select {
            width: 200px;
        }

        .item_box {
            padding-left: 80px;
            margin: 10px 0;
        }
    </style>
</head>
<body>
<div id="main_C">
    <div class="content_box">
        <div class="item_box">
            <span>选择优惠券</span>
            <div class="input-group-btn" style="display: inline-block;">
                <select id="coupon" name="type" class="form-control"
                        style="color: #959595;background: #eeeeee;border-bottom-left-radius: 3px;border-top-left-radius: 3px;">
                    <if condition="$_SESSION['kf_manager'] eq 1">
                        <option value="11">抵扣券</option>
                    <else/>
                        <option value="7">亲亲券</option>
                    </if>
                </select>
            </div>
        </div>
        <div class="item_box">
            <span>面额</span>
            <div class="" style="display: inline-block;">
                <if condition="$_SESSION['kf_manager'] eq 1">
                    <input type="number" style="width: 160px ;height: 30px" id="money"/>
                    <else/>
                    <select id="money" name="type" class="form-control"
                            style="color: #959595;background: #eeeeee;border-bottom-left-radius: 3px;border-top-left-radius: 3px;">
                        <option value="1">10</option>
                        <option value="2">20</option>
                        <option value="3">30</option>
                        <option value="4">40</option>
                        <option value="5">50</option>
                        <option value="6">60</option>
                    </select>
                </if>
            </div>
        </div>
        <button style="float: right;width: 100px;margin-right: 60px" class="btn btn-info" id="search_submit"
                onclick="send_coupon()">派送
        </button>
    </div>
</div>

<script src="/Public/js/jquery-3.2.1.js"></script>
<script src="/Public/js/layer/layer.js"></script>
<script src="/Public/js/layui/layui.js"></script>
<script src="/Public/js/toast.js"></script>
<script>

    function send_coupon() {
        var money = $("#money").val();
        var phone = "<{$phone}>";
        console.log('111111111money', money);
        if (phone == "" || phone == null) {
            $('#action').toast({
                content: '没有选择用户！',
                duration: 1000
            });
            return false;
        }
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var url = "<{$SERVER_NAME}>/User/coupon_send";

        layer.alert("确定赠送", {title: '提示框', icon: 3}, function (index) {
            $.post(url, {phone: phone, money: money}, function (data) {
                if (data.code == "1001") {
                    layer.alert(data.result, function (index) {
                        var index1 = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index1);
                    });
//                    $('#action').toast({
//                        content: '赠送成功！',
//                        duration: 1000
//                    });
                } else {
                    layer.alert(data.result);
                }
            });
            layer.close(index);
        });
        layer.close(index);

    }


</script>


</body>
</html>